package cn.edu.hqu.javae.domain;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.PrePersist;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import lombok.Data;
@Data
@Entity
@Table(name="Xk_Im")
public class Im {
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Long id;
	private Date placedAt;
	 @NotBlank(message="Name is required")
	  private String name;
	  @NotBlank(message="Sex is required")
	  private String sex;
	  @NotBlank(message="Age is required")
	  private String age;
	  @NotBlank(message="No is required")
	  private String no;
	  @ManyToMany(targetEntity=Xk.class)
	  private List<Xk> xks=new ArrayList<>();
		public void addDesign(Xk course) {
			this.xks.add(course);
		}
	  @PrePersist
		void placeAt() {
			this.placedAt=new Date();
		}
}
